package com.wushi.lenovo.asia5b.app_ui.shopcar.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wushi.lenovo.asia5b.R;
import com.wushi.lenovo.asia5b.app_model.good.ShopModel;

import java.util.List;

/**
 * Created by zhangyuncai on 2020/3/2.
 * 购物车店铺UI,包含若干商品
 */
public class OrderCheckPiShopAdapter extends BaseQuickAdapter<ShopModel, BaseViewHolder> {
    public boolean isDaigouGoods = false;

    public OrderCheckPiShopAdapter(@Nullable List<ShopModel> data) {
        super(R.layout.item_ordercheckpi_shopadapter, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopModel item) {

        //店铺icon
        ImageView iv_shop_shopicon=helper.getView(R.id.iv_shop_shopicon);
        iv_shop_shopicon.setSelected(!isDaigouGoods);

        //店铺名
        helper.setText(R.id.tv_shop_shopname, item.shop_name);

        //店铺中国物流费用
        helper.setText(R.id.tv_shop_chinafreeprice, item.domestic_fee_text);
        helper.setGone(R.id.tv_shop_chinafreeprice,isDaigouGoods);
        helper.setGone(R.id.tv_shop_chinafreeprice_text,isDaigouGoods);

        //店铺总价格
        helper.setText(R.id.tv_shop_totalprice, item.total_text);

        RecyclerView recyclerView = helper.getView(R.id.rv_shop);
        if (item.products != null && item.products.size() > 0) {
            helper.setGone(R.id.rv_shop, true);
            //商品列表
            OrderCheckPiGoodsAdapter goodsAdapter = new OrderCheckPiGoodsAdapter(item.products,isDaigouGoods);
            recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
            recyclerView.setAdapter(goodsAdapter);
        } else {
            helper.setGone(R.id.rv_shop, false);
        }

    }
}
